let bmapPromise

export function lazyBmapLoader() {
	if (window.Bmap) {
		return Promise.resolve()
	}
	if (bmapPromise) {
		return bmapPromise
	}
	let script = document.createElement('script')
	script.type = 'text/javascript'
	script.async = true
	script.src = 'https://api.map.baidu.com/api?v=2.0&ak=OjVfI3ARMRw9j9GyCk3UPMYHCg7NOHwM&callback=baiduMapapi'
	document.head.appendChild(script)
	bmapPromise = new Promise((resolve, reject) => {
		script.onload = () => {
			resolve()
		}
		script.onerror = error => {
			reject(error)
		}
	})
}
